<template>
	<view>
		<view class="header">
			<view class="detailNaver">
				<view @click="backTo" class="backMytask"><image src="/static/images/back.png"></image></view>
				<view class="status">{{ title }}</view>
				<view></view>
			</view>
			<view>当前{{ font }}</view>
			<view class="headerCenter">
				<view class="centerLeft">
					<text>{{ number }}</text>
					<text>{{ font }}</text>
				</view>
				<view v-if="font == '车币'" @click="goToWithdraw" class="centerRight">
					<text>提现</text>
					<image src="/static/images/white-right.png"></image>
				</view>
			</view>
			<view>您已获得{{ number }}{{ font }}</view>
		</view>

		<view class="particulars">{{ font }}明细</view>
		
		<!-- 车豆明细 -->
		<view class="particuList">
			<view v-for="(item, index) in recordList" :key="index" class="item">
				<view class="itemLeft">
					<view class="itemLeft-top">{{ item.mark }}</view>
					<view class="itemLeft-btm">{{ item.create_time }}</view>
				</view>
				<view class="itemRight">
					<text v-if="item.pm == 0">-</text>
					<text v-else>+</text>
					<text>{{ item.number }}</text>
				</view>
			</view>
			<view v-if="font == '车豆' && !recordList.length" class="notAvailable">暂无明细~</view>
		</view>
		<!-- 车币明细 -->
		<view class="particuList">
			<view v-for="(item, index) in withdrawList" :key="index" class="item">
				<view class="itemLeft">
					<view class="itemLeft-top">
						<text v-if="item.extract_type == 0">银行卡提现</text>
						<text v-else-if="item.extract_type == 1">微信提现</text>
						<text v-else="item.extract_type == 2">支付宝提现</text>
					</view>
					<view class="itemLeft-btm">{{ item.create_time }}</view>
				</view>
				<view class="itemRight">
					<text>- {{ item.extract_price }}</text>
				</view>
			</view>
			<view v-if="font == '车币' && !withdrawList.length && !recordList.length" class="notAvailable">暂无明细~</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			title: '',
			number: '',
			recordList: [],
			withdrawList: []
		};
	},
	onLoad(e) {
		if (e.type == 0) {
			this.title = '我的车豆';
			this.font = '车豆';
			this.getBean();
		} else {
			this.title = '我的车币';
			this.font = '车币';
			this.getCoin();
			this.getHaibiList();
		}
		this.number = e.num;
	},
	methods: {
		goToWithdraw(url) {
			uni.navigateTo({
				url: '/pages/users/user_cash/index'
			});
		},
		// 返回
		backTo() {
			uni.navigateBack();
		},
		// 获取我的车豆
		getBean() {
			this.$api.getUserBean(res => {
				this.recordList = res.data;
			});
		},
		// 获取我的车币
		getCoin() {
			this.$api.getUserCoin(res => {
				this.recordList = res.data;
			});
		},
		// 获取提现记录
		getHaibiList() {
			this.$api.getHaibiList(res => {
				this.withdrawList = res.data;
			});
		}
	}
};
</script>

<style lang="less">
.header {
	background-image: url(../../../static/images/background11.png);
	background-repeat: no-repeat;
	background-size: 100% 100%;
	height: 375rpx;
	font-size: 26rpx;
	color: #ffffff;
	padding: 0 30rpx;
	.detailNaver {
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 88rpx;
		margin-bottom: 20rpx;
		.backMytask {
			width: 20rpx;
			height: 35rpx;
			image {
				width: 100%;
				height: 100%;
			}
		}
		.status {
			font-size: 35rpx;
			color: #ffffff;
		}
	}
	.headerCenter {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 20rpx 0;
		.centerLeft {
			text:nth-child(1) {
				font-size: 78rpx;

				margin-right: 10rpx;
			}
			text:nth-child(2) {
				font-size: 28rpx;
			}
		}
		.centerRight {
			font-size: 32rpx;
			text {
				vertical-align: middle;
				margin-right: 20rpx;
			}
			image {
				width: 15rpx;
				height: 25rpx;
				vertical-align: middle;
				margin-top: 6rpx;
			}
		}
	}
}

.particulars {
	font-size: 36rpx;
	font-weight: 400;
	color: #1a1a1a;
	width: 670rpx;
	margin: 20rpx auto;
}

.particuList {
	.item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 710rpx;
		height: 150rpx;
		background: #ffffff;
		box-shadow: 0px 0px 28rpx 0px rgba(48, 48, 48, 0.1);
		border-radius: 8rpx;
		margin: 0 auto 20rpx;
		padding: 0 20rpx;
		.itemLeft {
			.itemLeft-top {
				font-size: 28rpx;
				font-weight: bold;
				color: #333333;
				margin-bottom: 20rpx;
			}
			.itemLeft-btm {
				font-size: 24rpx;
				font-weight: 400;
				color: #808080;
			}
		}
		.itemRight {
			font-size: 40rpx;
			// font-weight: bold;
			color: #fe3f10;
		}
	}
	.notAvailable {
		width: 100%;
		height: 150rpx;
		text-align: center;
		line-height: 200rpx;
		font-size: 24rpx;
		color: #666;
		margin-top: 200rpx;
	}
}
</style>
